﻿

using UnityEngine;

namespace View
{
    public abstract class AbstractView : IView
    {
        public string Name { get; set; }
        public GameObject Context
        {
            get { return gameObject; }
            set
            {
                gameObject = value;
                transform = gameObject.transform;
            }
        }

        public GameObject gameObject;
        public Transform transform;

        public void Load()
        {
            this.OnLoad();
        }

        public void Show(params object[] args)
        {
            Context.SetActive(true);
            this.OnShow(args);
        }

        public void Close(params object[] args)
        {
            this.OnClose(args);
            Context.SetActive(false);



        }

        public virtual void OnDisConnect()
        {

        }

        public abstract void OnLoad();
        public abstract void OnShow(params object[] args);
        public abstract void OnClose(params object[] args);
        public void Destory()
        {
            GameObject.Destroy(Context);
        }
    }
}
